<?php
class Server {
  public static function submit_obj($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    if ($req->name == '') {
      echo 'Name is empty';
      return;
    }
    
    if (isset($req->id)) {
      $orm->update('pb_ecom_tag', $req);
    } else {
      $orm->add('pb_ecom_tag', $req);
      $req->id = $orm->last_id();
    }
    echo json_encode($req);
  }
  
  public static function delete_obj($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    $orm->delete('pb_ecom_tag', $req);
  }
}
?>